package com.ruoyi.performance.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.performance.domain.PerfDirectScore;
import com.ruoyi.performance.service.PerfDirectScoreService;
import com.ruoyi.performance.utils.MyUtils;

import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @author YL
 * @date 2020-07-22
 * @description 绩效细项打分控制层
 */
@RestController
@RequestMapping("direct")
public class PerfDirectScoreController extends MyUtils {
	
	@Resource
	private PerfDirectScoreService perfDirectScoreService;

	/**
     * 根据细项ditemId查找绩效细项打分
     * @param ditemId 细项id
     * @return 绩效细项打分明细
     */
	@GetMapping("get/{ditemId}")
	public R list(@PathVariable("ditemId") int ditemId){
		Map<String, Object> m = new HashMap<>(16);
		m.put("rows", perfDirectScoreService.selectPerfDirectScoreById(ditemId));
		return R.ok(m);
	}
	
	/**
	 * 新增保存绩效细项打分明细
	 */
	@PostMapping("save")
	public Map<String,String> addSave(@RequestBody PerfDirectScore perfDirectScore) {
		return jacResultMsg(perfDirectScoreService.insertPerfDirectScore(perfDirectScore));
	}

	/**
	 * 修改保存绩效细项打分明细
	 */
	@PostMapping("update")
	public Map<String,String> editSave(@RequestBody PerfDirectScore perfDirectScore) {
		return jacResultMsg(perfDirectScoreService.updatePerfDirectScore(perfDirectScore));
	}

	
}
